import { BaseDetailPenel } from "./BaseDetailPenel";
import { Cache } from "../../../cache/Cache";
import { ENpcEffect } from "../../../../../Message/Public/ENpcEffect";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { FlyFootBmp } from "../../mapUI/flyFoot/FlyFootBmp";
import { SGuildStructureInfo } from "../../../../../Message/Game/SGuildStructureInfo";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { BuildingImage } from "./BuildingImage";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
type int = number;
//class PasturePanel
    
    export  class PasturePanel extends BaseDetailPenel
    {
        constructor()
        {
            super();
            this.init();
            createCommon();
            currentFundsLabel.y = 215;
            currentFundsInput.y = 212;
            this._npcTarget = Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectCopy147);
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 505, 100, this);
            ObjCreate.createBg(0, 105, 505, 160, this);
            ObjCreate.createBg(0, 270, 505, 110, this);
            this._baseSprite = new Object /* flash.display.Sprite */();
            this.addChild(this._baseSprite);
            this._nameText = ObjCreate.createTextField("", 30, 5, 220, 20, this._baseSprite, GlobalStyle.textFormat2);
            statusText = ObjCreate.createTextField("", 85, 5, 220, 20, this._baseSprite, GlobalStyle.textFormat5);
            ObjCreate.createTextField(Language.getString(57124), 30, 30, 220, 20, this._baseSprite);
            this._levelText = ObjCreate.createTextField("", 95, 30, 220, 20, this._baseSprite, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(57125), 30, 60, 220, 20, this._baseSprite);
            this._levelLimitText = ObjCreate.createTextField("", 95, 60, 220, 20, this._baseSprite, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(57126), 170, 30, 220, 20, this._baseSprite);
            this._descText = ObjCreate.createTextField("", 192, 47, 240, 40, this._baseSprite);
            this._descText.wordWrap = true;
            this._descText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._upgradeSprite = new Object /* flash.display.Sprite */();
            this._upgradeSprite.x = 70;
            this._upgradeSprite.y = 105;
            this.addChild(this._upgradeSprite);
            ObjCreate.createTextField(Language.getString(57128), 160, 5, 220, 20, this._upgradeSprite, GlobalStyle.textFormat2);
            ObjCreate.createBg(15, 30, 68, 70, this._upgradeSprite, ImagesConst.itemBigBg);
            this._buildItem = new BaseItem();
            this._buildItem.width = 62;
            this._buildItem.height = 62;
            this._buildItem.x = 19;
            this._buildItem.y = 33;
            this._upgradeSprite.addChild(this._buildItem);
            ObjCreate.createTextField(Language.getString(57129), 95, 30, 220, 20, this._upgradeSprite);
            this._effectText = ObjCreate.createTextField("", 120, 50, 300, 20, this._upgradeSprite);
            this._effectText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._effectText.multiline = true;
            this._effectText.wordWrap = true;
            ObjCreate.createTextField(Language.getString(57130), 95, 90, 220, 20, this._upgradeSprite);
            consumeTxt = ObjCreate.createGTextField(Language.getString(57131), 120, 110, 220, 20, this._upgradeSprite);
            fundsInput = ObjCreate.createGTextInput(180, 107, 60, 20, this._upgradeSprite);
            fundsInput.setStyle("textFormat", GlobalStyle.textFormat6);
            fundsInput.editable = false;
            this._upNameText = ObjCreate.createTextField("", 15, 100, 65, 20, this._upgradeSprite);
            this._upNameText.autoSize = flash.text.TextFieldAutoSize.CENTER;
            upgradeBtn = ObjCreate.createGButton(Language.getString(57132), 165, 130, 65, 24, this._upgradeSprite);
            this._activityTxt = ObjCreate.createTextField("", 20, 280, 490, 100, this);
            this._activityTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._activityTxt.multiline = true;
            this._activityTxt.htmlText = Language.getString(57592);
            this._goTxt = ObjCreate.createTextField("", 415, 10, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            this._goTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._goTxt.htmlText = Language.getString(57500);
            this._goTxt.addEventListener(flash.events.TextEvent.LINK, this.onLinkClickHandler);
            this._flyFoot = new FlyFootBmp();
            this._flyFoot.x = 470;
            this._flyFoot.y = 8;
            this._flyFoot.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyFootClickHandler);
            this.addChild(this._flyFoot);
            return;
        }

        public updateBuildInfoPanel(arg1: SGuildStructureInfo): void
        {
            var structureInfo: SGuildStructureInfo;
            var type: int;

            var loc1;
            type = 0;
            structureInfo = arg1;
            this.structureInfo = structureInfo;
            if (structureInfo) 
            {
                type = structureInfo.type.__value;
                this._levelLimitText.text = maxLevel.toString();
                this._nameText.text = GameDefConfig.instance.getGuildBuildingName(type);
                this._upNameText.text = this._nameText.text;
                this._levelText.text = structureInfo.level.toString();
                this._descText.htmlText = "<textFormat leading=\'5\'>" + GameDefConfig.instance.getGuildBuildingDesc(type) + "</textFormat>";
                this._effectText.htmlText = "<textFormat leading=\'5\'>" + GameDefConfig.instance.getGuildBuildingUpgradeDesc(type) + "</textFormat>";
                LoaderManager.instance.load(BuildingImage.getImageName(type), (arg1: ImageInfo): void
                {
                    _buildItem.source = arg1.bitmapData;
                    return;
                })
                runPublic();
            }
            return;
        }

        /* internal  */onLinkClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (this._npcTarget) 
            {
                AIManager.onAutoPathAIControl(this._npcTarget);
            }
            return;
        }

        /* internal  */onFlyFootClickHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._npcTarget) 
            {
                AIManager.onAIControl(this._npcTarget, AIType.AI_Convey);
            }
            return;
        }

        /* internal */ /* var */_baseSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_upgradeSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_nameText: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelText: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelLimitText: Object /* flash.text.TextField */;

        /* internal */ /* var */_descText: Object /* flash.text.TextField */;

        /* internal */ /* var */_effectText: Object /* flash.text.TextField */;

        /* internal */ /* var */_upNameText: Object /* flash.text.TextField */;

        /* internal */ /* var */_buildItem: BaseItem;

        /* internal */ /* var */_openBtn: GButton;

        /* internal */ /* var */_activityTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_goTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_flyFoot: FlyFootBmp;

        /* internal */ /* var */_npcTarget: TaskTargetInfo;
    }
